<div id="main-content">
  <div class="container-fluid" style="padding-left: 0px;padding-right: 0px;">
    <ul class="breadcrumb">
      <li><a href="<?php print site_url("frm/accounting/journal")?>"><?php print lang('frm_journal')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/journal-log/".$id_frm_journal)?>"><?php print lang('frm_journal_transaksi')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/all-buku-besar/".$id_frm_journal)?>"><?php print lang('frm_buku_besar')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/neraca/".$id_frm_journal)?>"><?php print lang('frm_neraca')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/neraca-penyesuaian/".$id_frm_journal)?>"><?php print lang('frm_neraca_penyesuaian')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/neraca-setelah-penyesuaian/".$id_frm_journal)?>"><?php print lang('frm_neraca_setelah_penyesuaian')?></a><span class="divider">»</span></li>
      <li><a href="<?php print site_url("frm/accounting/rugi-laba/".$id_frm_journal)?>"><?php print lang('frm_rugi_laba')?></a><span class="divider">»</span></li>
      <li class="active"><?php print $title?></li>
    </ul>
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-block">
          <?php
          if($status == '2'){
          ?>
          <div class="alert alert-error fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong><?php print urldecode($pesan)?></strong>
          </div>
          <?php
          }
          if($status == '1'){
          ?>
          <div class="alert alert-success fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong><?php print urldecode($pesan)?></strong>
          </div>
          <?php
          }
          ?>
          <div class="widget-head">
            <h5><?php print $title?></h5>
<!--            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("frm/accounting/journal-pajak/".$id_frm_journal) ?>"><i class="icon-plus"></i><?php print lang("frm_journal_pajak")?></a></li>
              </ul>
            </div>-->
          </div>
          <div class="widget-content" style="font-size: 75%">
            <div class="widget-box">
              <table class="table" border="1">
                <thead style="background-color: rgba(128, 128, 128, 0.33);">
                  <tr>
                    <th style=" vertical-align: middle; width: 4%" rowspan="2">No Akun</th>
                    <th style=" vertical-align: middle; width: 16%" rowspan="2">Name</th>
                    <th colspan="2" style="background-color: #fce4ea;">Neraca Percobaan</th>
                    <th colspan="2" style="background-color: #CCFF99">Neraca Penyesuaian</th>
                    <th colspan="2" style="background-color: #dcedcf">Neraca Setelah Disesuaikan</th>
                    <th colspan="2;" style="background-color: #99CCFF">Laba/ Rugi</th>
                    <th colspan="2" style="background-color: #fafbbd">Neraca</th>
                  </tr>
                  <tr>
                    <th style="width: 8%; background-color: #fce4ea;">Debit</th>
                    <th style="width: 8%; background-color: #fce4ea;">Kredit</th>
                    <th style="width: 8%; background-color: #CCFF99">Debit</th>
                    <th style="width: 8%; background-color: #CCFF99">Kredit</th>
                    <th style="width: 8%; background-color: #dcedcf">Debit</th>
                    <th style="width: 8%; background-color: #dcedcf">Kredit</th>
                    <th style="width: 8%; background-color: #99CCFF">Debit</th>
                    <th style="width: 8%; background-color: #99CCFF">Kredit</th>
                    <th style="width: 8%; background-color: #fafbbd">Debit</th>
                    <th style="width: 8%; background-color: #fafbbd">Kredit</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  if(is_array($neraca)){
                    foreach ($neraca['percobaan'] as $key => $value) {
                      $link_edit = site_url("frm/accounting/add-master-account/".$value->id_frm_account);
//                      $link_delete = site_url("keuangan/add-akun/".$outlet[0]->id_outlet."/".$value->id_akun);
                      $laba_debit = "";
                      $laba_kredit = "";
                      
                      $neraca_debit = "";
                      $neraca_kredit = "";
                      
                      if($value->pos == 1){
                        $name = "<a href='".site_url("frm/accounting/buku-besar/".$id_frm_journal."/".$value->id_frm_account)."'>".$value->title."</a>";
                        
                        $price_debit = "Rp ".number_format($value->saldo, 0, ",",".");
                        $price_kredit = "";
                        $total_debit += $value->saldo;
                        
                        $penyesuaian_debit = "Rp ".number_format($neraca['penyesuaian'][$key]->saldo, 0, ",",".");
                        $penyesuaian_kredit = "";
                        $penyesuaian_total_debit += $neraca['penyesuaian'][$key]->saldo;
                        
                        $fix_debit ="Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",", ".");
                        $fix_kredit ="";
                        $fix_total_debit += $value->saldo + $neraca['penyesuaian'][$key]->saldo;
                        
                        if($value->labarugi == 2){
                          $laba_debit = "Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",",".");
                          $laba_kredit = "";
                          $total_laba_debit += ($value->saldo + $neraca['penyesuaian'][$key]->saldo);
                        }
                        else{
                          $neraca_debit = "Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",",".");
                          $neraca_kredit = "";
                          $total_neraca_debit += ($value->saldo + $neraca['penyesuaian'][$key]->saldo);
                        }
                      }
                      else{
                        $name = "<a href='".site_url("frm/accounting/buku-besar/".$id_frm_journal."/".$value->id_frm_account)."'>".$value->title."</a>";
                        
                        $price_debit = "";
                        $price_kredit = "Rp ".number_format($value->saldo, 0, ",",".");
                        $total_kredit += $value->saldo;
                        
                        $penyesuaian_debit = "";
                        $penyesuaian_kredit = "Rp ".number_format($neraca['penyesuaian'][$key]->saldo, 0, ",",".");
                        $penyesuaian_total_kredit += $neraca['penyesuaian'][$key]->saldo;
                        
                        $fix_debit = "";
                        $fix_kredit = "Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",", ".");
                        $fix_total_kredit += $value->saldo + $neraca['penyesuaian'][$key]->saldo;
                        
                        if($value->labarugi == 2){
                          $laba_debit = "";
                          $laba_kredit = "Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",",".");
                          $total_laba_kredit += ($value->saldo + $neraca['penyesuaian'][$key]->saldo);
                        }
                        else{
                          $neraca_debit = "";
                          $neraca_kredit = "Rp ".number_format(($value->saldo + $neraca['penyesuaian'][$key]->saldo), 0, ",",".");
                          $total_neraca_kredit += ($value->saldo + $neraca['penyesuaian'][$key]->saldo);
                        }
                      }
                        
                      $labarugi = $modal = "<img src='{$url}img/cross_button.png' />";
                      if($value->labarugi == 2)
                        $labarugi = "<img src='{$url}img/checked.png' />";
                        
                      if($value->modal == 2)
                        $modal = "<img src='{$url}img/checked.png' />";
                        
                      print "
                  <tr>
                    <td>{$value->nomor}</td>
                    <td>{$name}</td>
                    <td style='text-align: right; background-color: #fce4ea;'>{$price_debit}</td>
                    <td style='text-align: right; background-color: #fce4ea;'>{$price_kredit}</td>
                    <td style='text-align: right; background-color: #CCFF99'>{$penyesuaian_debit}</td>
                    <td style='text-align: right; background-color: #CCFF99'>{$penyesuaian_kredit}</td>
                    <td style='text-align: right; background-color: #dcedcf'>{$fix_debit}</td>
                    <td style='text-align: right; background-color: #dcedcf'>{$fix_kredit}</td>
                    <td style='text-align: right; background-color: #99CCFF'>{$laba_debit}</td>
                    <td style='text-align: right; background-color: #99CCFF'>{$laba_kredit}</td>
                    <td style='text-align: right; background-color: #fafbbd'>{$neraca_debit}</td>
                    <td style='text-align: right; background-color: #fafbbd'>{$neraca_kredit}</td>
                  </tr>"
                  ;
                    }
                  }
                  ?>
                  <tr style='background-color: #f4da70'>
                    <td></td>
                    <td>Rugi Laba Sebelum Pajak</td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'><?php print number_format(($total_laba_kredit - $total_laba_debit), 0, ",", ".")?></td>
                  </tr>
                  <?php
//                  $kredit_pajak = $total_laba_kredit - $total_laba_debit;
//                  foreach ($neraca['pajak'] AS $knp => $vnp){
//                    if($vnp->pos == 2){
//                      $kredit_pajak += $vnp->saldo;
//                      $kredit_cetak_pajak = $vnp->saldo;
//                      $debit_cetak_pajak = "";
//                    }
//                    else{
//                      $debit_pajak += $vnp->saldo;
//                      $kredit_cetak_pajak = "";
//                      $debit_cetak_pajak = $vnp->saldo;
//                    }
//                    print "
//                  <tr style='background-color: #f4da70'>
//                    <td>{$vnp->nomor}</td>
//                    <td>{$vnp->title}</td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'></td>
//                    <td style='text-align: right;'>".number_format($debit_cetak_pajak, 0, ",", ".")."</td>
//                    <td style='text-align: right;'>".number_format($kredit_cetak_pajak, 0, ",", ".")."</td>
//                  </tr>"
//                  ;
//                  }
                  ?>
<!--                  <tr style='background-color: #f9ecb6'>
                    <td></td>
                    <td>Jumlah</td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'><?php print number_format($debit_pajak, 0, ",", ".")?></td>
                    <td style='text-align: right;'><?php print number_format($kredit_pajak, 0, ",", ".")?></td>
                  </tr>
                  <tr style='background-color: #f9ecb6'>
                    <td></td>
                    <td>Rugi Laba Setelah Pajak</td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'></td>
                    <td style='text-align: right;'><?php print number_format(($kredit_pajak - $debit_pajak), 0, ",", ".")?></td>
                  </tr>-->
                </tbody>
                <tfoot style="font-weight: bold; background-color: rgba(128, 128, 128, 0.33);">
                  <tr>
                    <td colspan="2" style="text-align: center">JUMLAH</td>
                    <td style="text-align: right; background-color: #fce4ea;">Rp <?php print number_format($total_debit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #fce4ea;">Rp <?php print number_format($total_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #CCFF99">Rp <?php print number_format($penyesuaian_total_debit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #CCFF99">Rp <?php print number_format($penyesuaian_total_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #dcedcf">Rp <?php print number_format($fix_total_debit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #dcedcf">Rp <?php print number_format($fix_total_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #99CCFF">Rp <?php print number_format($total_laba_debit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #99CCFF">Rp <?php print number_format($total_laba_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #fafbbd">Rp <?php print number_format(($total_neraca_debit), 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #fafbbd">Rp <?php print number_format(($total_neraca_kredit + $total_laba_kredit - $total_laba_debit), 0, ",", ".")?></td>
                  </tr>
                  <tr>
                    <td colspan="2" style="text-align: center"></td>
                    <td style="text-align: right; background-color: #fce4ea;"></td>
                    <td style="text-align: right; background-color: #fce4ea;"></td>
                    <td style="text-align: right; background-color: #CCFF99"></td>
                    <td style="text-align: right; background-color: #CCFF99"></td>
                    <td style="text-align: right; background-color: #dcedcf"></td>
                    <td style="text-align: right; background-color: #dcedcf"></td>
                    <td style="text-align: right; background-color: #99CCFF">Rp <?php print number_format(($total_laba_kredit - $total_laba_debit), 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #99CCFF"></td>
                    <td style="text-align: right; background-color: #fafbbd"></td>
                    <td style="text-align: right; background-color: #fafbbd"></td>
                  </tr>
                  <tr>
                    <td colspan="2" style="text-align: center"></td>
                    <td style="text-align: right; background-color: #fce4ea;"></td>
                    <td style="text-align: right; background-color: #fce4ea;"></td>
                    <td style="text-align: right; background-color: #CCFF99"></td>
                    <td style="text-align: right; background-color: #CCFF99"></td>
                    <td style="text-align: right; background-color: #dcedcf"></td>
                    <td style="text-align: right; background-color: #dcedcf"></td>
                    <td style="text-align: right; background-color: #99CCFF">Rp <?php print number_format($total_laba_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #99CCFF">Rp <?php print number_format($total_laba_kredit, 0, ",", ".")?></td>
                    <td style="text-align: right; background-color: #fafbbd"></td>
                    <td style="text-align: right; background-color: #fafbbd"></td>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>